package com.gjy.controller;

import com.gjy.dao.ScourseMapper;
import com.gjy.domain.Teacher;
import com.gjy.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
@RequestMapping("/tea")
public class TeacherController {

    @Autowired
    TeacherService teacherService;

    @Autowired
    ScourseMapper scourseMapper;

    @RequestMapping(value = "/teaLogin",method = RequestMethod.POST)
    public String teaLogin(@RequestParam("teaId") String name, @RequestParam("teaPassword") String password){
        List<Teacher> all = teacherService.findAll();
        if (!name.isEmpty()){
            int i = Integer.parseInt(name);
            for (Teacher teacher : all) {
                if (teacher.getId().equals(i) && teacher.getPassword().equals(password)) {
                    return "student";
                }
            }
        }
        return "error";
    }


}
